home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 10 / 010.d81 / pps #23 < prev    next >
Text File  |  2022-08-26  |  4KB  |  254 lines

  1.  
  2.  PEEKs, POKEs, and SYSes -- Part 23
  3.           by Alan Gardner
  4.  
  5.  
  6. ======================================
  7.  
  8. Location: 55296-56295   Hex:$D800-DBFF
  9. Official Label: none         Type: RAM
  10. Useful BASIC commands:      PEEK, POKE
  11.  
  12. --------------------------------------
  13.  
  14.   These 1000 locations are known
  15.  
  16. collectively as your color screen.
  17.  
  18. You are now 'looking' at all of these
  19.  
  20. locations.  Every text character is
  21.  
  22. associated with a color.  This is what
  23.  
  24. determines which colors you see on
  25.  
  26. screen.
  27.  
  28.   The locations start in the upper-
  29.  
  30. left hand corner and proceed across
  31.  
  32. the screen.  When you reach the right
  33.  
  34. side, you merely go back to the left
  35.  
  36. side, one line lower.  It's just like
  37.  
  38. reading a book.
  39.  
  40.   If you've read Part 22, you know
  41.  
  42. that we're working on left/right
  43.  
  44. scroll routine (actually only left
  45.  
  46. now).  You'll also know that our
  47.  
  48. prior example can really mess up
  49.  
  50. the color on your text screen!
  51.  
  52.   Here's a picture of our color
  53.  
  54. memory:
  55.  
  56.  
  57.   !{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!
  58.   !55296!55297!55298!55299!.... !
  59.   !     !     !     !     !     !
  60.   !{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!
  61.   !55336!55337!55338!55339!.... !
  62.   !     !     !     !     !     !
  63.   {CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}
  64.  
  65.  
  66. Have any ideas on what to do? (Hint:
  67.  
  68. remember Part 22 and the 8 steps.)
  69.  
  70. Did you guess moving what is in
  71.  
  72. location 55297 into location 55296,
  73.  
  74. then moving what is in location 55298
  75.  
  76. into location 55297, etc...
  77.  
  78.  
  79.  Again notice that if the location
  80.  
  81. is on the left side of the screen, we
  82.  
  83. move it off completely.  But what if
  84.  
  85. it is on the far-right side?  Well
  86.  
  87. we just fill those locations with the
  88.  
  89. current screen color.
  90.  
  91.  
  92.   Again we set a variable equal to the
  93.  
  94. base address of our color screen.
  95.  
  96.  
  97. 10 CS=55296: REM   base address
  98.  
  99.  
  100.   Next, just like our example for the
  101.  
  102. text screen, we need to have two
  103.  
  104. loops. One loop is for going across
  105.  
  106. the screen, and the other loop is for
  107.  
  108. going down the screen.
  109.  
  110.  
  111. 20 FOR Y=0to24  : REM  down screen
  112. 30 FOR X=0to38  : REM  across screen
  113.  
  114. (Doesn't this all look VERY familiar?)
  115.  
  116.  
  117. You might have noticed that we are
  118.  
  119. only going across for 39 locations
  120.  
  121. (0-38 is 39 characters).  This is
  122.  
  123. because we want to store the screen
  124.  
  125. color in the right-most location on
  126.  
  127. each line.
  128.  
  129.   Now we can use the same formula to
  130.  
  131. find out where we are on color screen:
  132.  
  133.  
  134.    COLOR=CS+40*Y+X
  135.  
  136. By using this formula, we can
  137.  
  138. calculate where we are on the screen.
  139.  
  140.  
  141. 40 COLR=CS+40*Y+X : REM  where are we?
  142.  
  143.  
  144. Now that we know where we are, we
  145.  
  146. can find out what is there and then
  147.  
  148. put it in the right place.  Because
  149.  
  150. we are scrolling left, we want to
  151.  
  152. 'look ahead' at the next location to
  153.  
  154. find out what to put in the current
  155.  
  156. location  (make sense?).
  157.  
  158.   Now for the rest of our program:
  159.  
  160.  
  161. 50 POKE COLR, PEEK(COLR+1)
  162. 60 NEXT X
  163. 70 POKE COLR+1,PEEK(53281)
  164. 80 NEXT Y
  165.  
  166.  
  167. Line 50 is the main step in our
  168.  
  169. program.  What it does is pick-up the
  170.  
  171. color in one location and put it into
  172.  
  173. the location directly to the left of
  174.  
  175. it.  For example, it takes out what is
  176.  
  177. in location 55297 and puts what it
  178.  
  179. finds into locations 55296. This
  180.  
  181. produces our scroll left effect for
  182.  
  183. color. Line 70 is to put the screen
  184.  
  185. color into right-most locations.
  186.  
  187.   That's all there is to scrolling the
  188.  
  189. color screen.  Now, if we combine our
  190.  
  191. two routines, we have a working
  192.  
  193. scroll left routine.  Let's take a
  194.  
  195. look at the finished product.
  196.  
  197.  
  198. 10 BA=1024:CS=55296
  199. 20 FORY=0to24
  200. 30 FORX=0to38
  201. 40 ADDR=BA+40*Y+X:COLR=CS+40*Y+X
  202. 50 POKE ADDR,PEEK(ADDR+1)
  203. 55 POKE COLR,PEEK(COLR+1)
  204. 60 NEXT X
  205. 70 POKE ADDR+1,32
  206. 75 POKE CORL+1,PEEK(53281)
  207. 80 NEXT Y
  208.  
  209.  
  210. And that's it!!  We now have a
  211.  
  212. scroll left routine.  It's a bit(??)
  213.  
  214. slow, but it gets the job done.
  215.  
  216.   Because it is so slow, I have
  217.  
  218. included a machine-language routine
  219.  
  220. of the same thing, with the added
  221.  
  222. feature of scrolling right.  It is
  223.  
  224. saved under the name of SCROLL.L/R
  225.  
  226. on side 1 on this issue of LOADSTAR.
  227.  
  228. To use this routine in a program, here
  229.  
  230. is all you need:
  231.  
  232.  
  233. 10 IFX=0THENX=1:LOAD"SCROLL.L/R",8,1
  234. 20 :
  235. 30 REM     SYS 49152 to scroll left
  236. 40 REM     SYS 49155 to scroll right
  237. 50 :
  238. 60 REM   Your program continues here!
  239.  
  240.  
  241. Hope you can use this program and I
  242.  
  243. hope you have learned something. I
  244.  
  245. will leave learning how to scroll
  246.  
  247. right up to you, but I will tell you
  248.  
  249. that it is VERY similar to scrolling
  250.  
  251. left.
  252.  
  253. ---------- end of article ------------
  254.